/**
 * 测试setitimer函数；
 * @author: sundx
 * @date: 2020-05-23 06:45:30
 * @Last Modified by: sundx
 * @Last Modified time: 2020-05-23 23:09:34
 */
#include <iostream>
#include <signal.h>
#include <sys/time.h>
#include <unistd.h>
void dealSig(int);
int main() {
  struct itimerval newTimer, oldTimer;
  newTimer.it_interval.tv_sec = 0; // 周期定时秒数
  newTimer.it_interval.tv_usec = 0;
  newTimer.it_value.tv_sec = 1; //第一次定时秒数
  newTimer.it_value.tv_usec = 0;
  setitimer(ITIMER_REAL, &newTimer, &oldTimer); // oldTimer是传出
  int i = 1;
  while (i++) {
    // std::cout << i << std::endl;
    printf("%d/n", i);
  }
  return 0;
}
